/*
 *    This file is part of BlobDB.
 *
 *    BlobDB is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    BlobDB is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with BlobDB.  If not, see <http://www.gnu.org/licenses/>.
 *    
 *    Copyright(c) 2011 Michael Kankkonen
 *    http://www.vnetcon.org
 */


package org.vnetcon.blobdb.database.util.parser;

import java.util.ArrayList;

import org.vnetcon.blobdb.database.SQLException;

public class DropTableParser {

	private ArrayList<String> elements = null;

	private String table = null;

	public DropTableParser(ArrayList<String> elements) throws SQLException{
		this.elements = elements;
		init();
	}
	
	private void init() throws SQLException{
		initTable();
	}
	
	public String getTable(){
		return this.table;
	}

	private void initTable() throws SQLException {
		String buf = null;
		table = elements.get(2);
		
		if(elements.size() < 4){
			throw new SQLException("Expecting ';' after tablename.");
		}		
		buf = elements.get(3);
		if(!buf.equals(";")){
			throw new SQLException("Expecting ';' after tablename.");
		}
	}
	
}
